package cc.fs.study.drawandevent;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.ImageView;
import android.widget.TextView;

public class DrawTextView extends TextView {
    public DrawTextView(Context context) {
        super(context);
    }

    public DrawTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public DrawTextView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
//        e("onMeasure");
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
//        e("onLayout");
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
//        e("onDraw");
    }

   public void e(String msg){
       Log.e(this.getClass().getSimpleName(),msg);
   }

    //是否消耗当前事件
    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        e("消耗事件");
        return super.dispatchTouchEvent(ev);
    }

    //处理当前事件
    @Override
    public boolean onTouchEvent(MotionEvent event) {
        e("处理事件");
        return super.onTouchEvent(event);
    }
}